<template>
  <el-carousel :interval="4000" type="card" height="270px"  v-loading="loading"  >
    <el-carousel-item class="item" v-for="item in imglist" :key="item.isbn">
     <router-link :to="{path:'/book',query:{id:item.flBook.isbn}}" @click.native="dianji(item.bookId)">
      <el-image
        referrer="no-referrer|origin|unsafe-url"
          style=" height: 270px;"
         :src=" item.topImg"
          fit="fill"></el-image>
     </router-link>
    </el-carousel-item>
  </el-carousel>
</template>

<style scoped>
  .el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 50px;
    margin: 0;
  }
  
  .el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
  }
  
  .el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
  }
 
</style>
<<script>
import axios from "axios";

export default {
  data() {
    return {
        imglist:[],
        loading:true,
    }
  },
  methods:{
      dianji(val){   //点击量
    let params = new URLSearchParams();
    params.append("bookId", val);
      axios.post('/fl-book/addBookHits',params).then((res)=>{
        
      })
    },
    getlunbo(){
       axios
        .get("/fl-book/shufflingFigure", {
          params: {
           
          },
        })
        .then((res) => {
          
          
          this.imglist = res.data.data;
          this.loading=false;
        }) .catch((error) => {
            this.$message({
                        message: "请求超时，请检查网络连接",
                        type: "error"
                    })
          });
    }
  }, 
  created() {
    this.getlunbo();

  }
}
</script>